import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/6 10:43
 * @description 首先求出 p[0], 然后利用 e[i] = p[i]^ p[i + 1] 得知，p[i + 1] = p[i]^e[i]
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int[] decode(int[] encoded) {
        int n = encoded.length + 1;
        int total = 0;
        for (int i = 1; i <= n; i++) {
            total ^= i;
        }
        // encode中所有奇数下标的异或 = 为源数组中除了p[0]以为的数异或
        int odd = 0;
        for (int i = 1; i < n - 1; i += 2) {
            odd ^= encoded[i];
        }
        int[] ans = new int[n];
        ans[0] = total ^ odd;
        for (int i = 0; i < n - 1; i++) {
            ans[i + 1] = ans[i] ^ encoded[i];
        }
        return ans;
    }
}
